<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('员工持证情况')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
</head>
<style>
    select {
        padding-top: 3px !important;
    }

    .select-list {
        margin-top: 5px !important;
    }

    .select-list li p {
        width: auto !important;
        margin-top: 7px !important;
    }

    .form-header {
        margin: 10px auto !important;

    }

    .table-striped .table > thead:first-child > tr:first-child > th {
        font-weight: normal;
        font-size: 13px;
        border: 1px solid #cccccc;
        border-right: none;
        border-top: 1px solid #cccccc !important;
    }
</style>
<body class="gray-bg">
<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="project-form">
                    <div class="col-sm-12">
                        <div class="select-list">
                            <ul>
                                <li>
                                    <p>单位：</p>
                                    <select name="compId" id="compId" class="form-control">
                                        <option value="">请选择</option>
                                        <option th:each="pro:${userComp}" th:value="${pro.compId}"
                                                th:text="${pro.compName}"></option>
                                    </select>
                                </li>
                                <li>
                                    <p>年份：</p>
                                    <select name="years" id="years" class="form-control">
                                        <option value="">请选择</option>
                                        <option value="2020">2020</option>
                                        <option value="2021">2021</option>
                                        <option value="2022">2022</option>
                                        <option value="2023">2023</option>
                                        <option value="2024">2024</option>
                                        <option value="2025">2025</option>
                                    </select>
                                </li>
                                <li>
                                    <p>月份：</p>
                                    <select name="months" id="months" class="form-control">
                                        <option value="">请选择</option>
                                        <option value="1">一月</option>
                                        <option value="2">二月</option>
                                        <option value="3">三月</option>
                                        <option value="4">四月</option>
                                        <option value="5">五月</option>
                                        <option value="6">六月</option>
                                        <option value="7">七月</option>
                                        <option value="8">八月</option>
                                        <option value="9">九月</option>
                                        <option value="10">十月</option>
                                        <option value="11">十一月</option>
                                        <option value="12">十二月</option>
                                    </select>
                                </li>
                                <li>
                                    <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                            class="fa fa-search"></i>&nbsp;搜索</a>
                                    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                            class="fa fa-refresh"></i>&nbsp;重置</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </form>
            </div>
            <div class="col-sm-12 select-table table-striped">

                <div class="btn-group-sm" id="toolbar" role="group">
                    <a class="btn btn-success" onclick="$.operate.add()">
                        <i class="fa fa-plus"></i> 新增
                    </a>
                    <a class="btn btn-primary single disabled" onclick="$.operate.edit()">
                        <i class="fa fa-edit"></i> 修改
                    </a>
                    <!--<a class="btn btn-danger" onclick="remove()">-->
                        <!--<i class="fa fa-remove"></i> 删除-->
                    <!--</a>-->
                    <a class="btn btn-warning" onclick="exportEmpChange()">
                        <i class="fa fa-download"></i> 导出
                    </a>
                </div>
                <table id="empCertificate-table"></table>
                <div class="col-sm-12 sum"></div>
            </div>

        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<script th:inline="javascript">
    var prefix = ctx + "empCertificate";
    var value;
    $(function () {
        var empCertificate_options = {
            url: prefix + '/list',
            uniqueId: "id",
            id: 'empCertificate-table',
            createUrl: prefix + "/add",
            removeUrl: prefix + "/remove",
            updateUrl: prefix + "/edit/{id}",
            modalName: "持证情况",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            pagination:false,
            rowStyle: function (row, index) {
                var style = {};
                style={css:{'color':'#ed5565','font-weight':'700'}};

                if(row.compName=='合计'){
                    return style;
                }else {
                    return '';
                }

            },
            columns: [
                [
                    {
                        checkbox: true,
                        rowspan: 2,
                        valign: "middle",
                        align: "center"
                    },
                    {
                        field: 'compName',
                        title: '工程公司名称',
                        rowspan: 2,
                        valign: "middle",
                        align: "center"

                    },
                    {
                        field: 'years',
                        title: '年份',
                        rowspan: 2,
                        valign: "middle",
                        align: "center"

                    },
                    {
                        field: 'months',
                        title: '月份',
                        rowspan: 2,
                        valign: "middle",
                        align: "center"

                    },
                    {
                        title: '建筑工程类',
                        rowspan: 1,
                        colspan: 6,
                        align: "center"
                    },
                    {
                        title: '人资类',
                        rowspan: 1,
                        colspan: 2,
                        align: "center"
                    },
                    {
                        title: '财务类',
                        rowspan: 1,
                        colspan: 4,
                        align: "center"
                    },
                ],
                [
                    {
                        field: 'firstConstructionNum',
                        title: '一建',
                        align: "center"
                    },
                    {
                        field: 'secondConstructionNum',
                        title: '二建',
                        align: "center"
                    },
                    {
                        field: 'costEngineerNum',
                        title: '造价师',
                        align: "center"
                    },
                    {
                        field: 'securityANum',
                        title: '安全A证',
                        align: "center"
                    },
                    {
                        field: 'securityBNum',
                        title: '安全B证',
                        align: "center"
                    },
                    {
                        field: 'securityCNum',
                        title: '安全C证',
                        align: "center"
                    },
                    {
                        field: 'humanResourcesOneNum',
                        title: '人力资源一级',
                        align: "center"
                    },
                    {
                        field: 'humanResourcesTowNum',
                        title: '人力资源二级',
                        align: "center"
                    },
                    {
                        field: 'registerAccountingNum',
                        title: '注册会计师',
                        align: "center"
                    },
                    {
                        field: 'seniorAccountingNum',
                        title: '高级会计师',
                        align: "center"
                    },
                    {
                        field: 'intermediateAccountingNum',
                        title: '中级会计师',
                        align: "center"
                    },
                    {
                        field: 'assistantAccountingNum',
                        title: '助理会计师',
                        align: "center"
                    }
                ]
            ]
        }
        $.table.init(empCertificate_options);
        //sum();
    })

    // function sum() {
    //     setTimeout(function () {
    //         value = $("#empCertificate-table").bootstrapTable('getData');
    //         var firstConstructionNum = 0;//一建
    //         var secondConstructionNum = 0;//二建
    //         var costEngineerNum = 0;//造价师
    //         var securityANum = 0;//安全A证
    //         var securityBNum = 0;//安全B证
    //         var securityCNum = 0;//安全C证
    //         var humanResourcesOneNum = 0;//人力资源一级
    //         var humanResourcesTowNum = 0;//人力资源二级
    //         var registerAccountingNum = 0;//注册会计师
    //         var seniorAccountingNum = 0;//高级会计师
    //         var intermediateAccountingNum = 0;//中级会计师
    //         var assistantAccountingNum = 0;//助理会计师
    //         for (var i in value) {
    //
    //             firstConstructionNum += Number(value[i].firstConstructionNum);
    //             secondConstructionNum += Number(value[i].secondConstructionNum);
    //             costEngineerNum += Number(value[i].costEngineerNum);
    //             securityANum += Number(value[i].securityANum);
    //             securityBNum += Number(value[i].securityBNum);
    //             securityCNum += Number(value[i].securityCNum);
    //             humanResourcesOneNum += Number(value[i].humanResourcesOneNum);
    //             humanResourcesTowNum += Number(value[i].humanResourcesTowNum);
    //             registerAccountingNum += Number(value[i].registerAccountingNum);
    //             seniorAccountingNum += Number(value[i].seniorAccountingNum);
    //             intermediateAccountingNum += Number(value[i].intermediateAccountingNum);
    //             assistantAccountingNum += Number(value[i].assistantAccountingNum);
    //         }
    //         var html;
    //         html = '<div class="col-sm-12" style="text-align: center;">' + '<h3 style="display: inline;">合计：</h3>' +
    //             '<div style="display: inline">' +
    //             "一建：" + '<sapan style="color: red;">' + firstConstructionNum + '</sapan>' + "；" +
    //             "二建：" + '<sapan style="color: red;">' + secondConstructionNum + '</sapan>' + "；" +
    //             "造价师：" + '<sapan style="color: red;">' + costEngineerNum + '</sapan>' + "；" +
    //             "安全A证：" + '<sapan style="color: red;">' + securityANum + '</sapan>' + "；" +
    //             "安全B证：" + '<sapan style="color: red;">' + securityBNum + '</sapan>' + "；" +
    //             "安全C证：" + '<sapan style="color: red;">' + securityCNum + '</sapan>' + "；" +
    //             "人力资源一级：" + '<sapan style="color: red;">' + humanResourcesOneNum + '</sapan>' + "；" +
    //             "人力资源二级：" + '<sapan style="color: red;">' + humanResourcesTowNum + '</sapan>' + "；" +
    //             "注册会计师：" + '<sapan style="color: red;">' + registerAccountingNum + '</sapan>' + "；" +
    //             "高级会计师：" + '<sapan style="color: red;">' + seniorAccountingNum + '</sapan>' + "；" +
    //             "中级会计师：" + '<sapan style="color: red;">' + intermediateAccountingNum + '</sapan>' + "；" +
    //             "助理会计师：" + '<sapan style="color: red;">' + assistantAccountingNum + '</sapan>' + "；" +
    //             '</div>' + '</div>';
    //         $(".sum").empty();
    //         $(".sum").append(html);
    //     }, 500);
    // }
    function remove() {
        $.operate.removeAll();
       $(".layui-layer-btn0").click(function () {
           sum();
       })
    }
    function exportEmpChange() {
        $('#empCertificate-table').bootstrapTable('hideColumn', 0);
        $("#empCertificate-table").tableExport({type: 'excel',
            fileName: '员工持证情况',
            exportDataType: "all",
        });
        $('#empCertificate-table').bootstrapTable('showColumn', 0);
    }
</script>
</body>
</html>